package com.sqfw.project.zj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.sqfw.project.zj.domain.ZjRecordScoreItem;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.project.zj.service.IZjRecordScoreItemService;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.web.page.TableDataInfo;

/**
 * 质检评分项Controller
 *
 * @author ruoyi
 * @date 2023-07-17
 */
@RestController
@RequestMapping("/zj/zj_record_score_item")
public class ZjRecordScoreItemController extends BaseController
{
    @Autowired
    private IZjRecordScoreItemService zjRecordScoreItemService;

    /**
     * 查询质检评分项列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ZjRecordScoreItem zjRecordScoreItem)
    {
        startPage();
        List<ZjRecordScoreItem> list = zjRecordScoreItemService.selectZjRecordScoreItemList(zjRecordScoreItem);
        return getDataTable(list);
    }

    /**
     * 导出质检评分项列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjRecordScoreItem zjRecordScoreItem)
    {
        List<ZjRecordScoreItem> list = zjRecordScoreItemService.selectZjRecordScoreItemList(zjRecordScoreItem);
        ExcelUtil<ZjRecordScoreItem> util = new ExcelUtil<ZjRecordScoreItem>(ZjRecordScoreItem.class);
        util.exportExcel(response, list, "质检评分项数据");
    }

    /**
     * 获取质检评分项详细信息
     */
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") String itemId)
    {
        return success(zjRecordScoreItemService.selectZjRecordScoreItemByItemId(itemId));
    }

    /**
     * 新增质检评分项
     */
    @PostMapping
    public AjaxResult add(@RequestBody ZjRecordScoreItem zjRecordScoreItem)
    {
        return toAjax(zjRecordScoreItemService.insertZjRecordScoreItem(zjRecordScoreItem));
    }

    /**
     * 修改质检评分项
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ZjRecordScoreItem zjRecordScoreItem)
    {
        return toAjax(zjRecordScoreItemService.updateZjRecordScoreItem(zjRecordScoreItem));
    }

    /**
     * 删除质检评分项
     */
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable String[] itemIds)
    {
        return toAjax(zjRecordScoreItemService.deleteZjRecordScoreItemByItemIds(itemIds));
    }
}
